﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "IMepCurve.h"
#include "GmepCategoryUniIdentities.h"
#include "IMepCurveType.h"
#include "WeakPtr.h"

namespace gcmp
{
    class ElementId;
}

namespace gmep
{
    /// \brief 线管创建输入参数
    struct DuctInput
    {
    public:
        DuctInput() :Document(nullptr), Visible(true), CreationOption(gcmp::ElementCreationOptions::Normal),
            CategoryUid(GmepCategoryUniIdentities::BICU_HVAC_DUCT),BaseOffset(0), IsUseBaseOffset(false),Diameter(0.0),Width(0.0),Height(0.0),CurveNormal(gcmp::Vector3d::UnitZ),
            horizontalAlignment(HorizontalAlignment::Center), verticalAlignment(VerticalAlignment::Middle)
        {}
        mutable gcmp::WeakPtr<gcmp::IDocument> Document; ///<文档指针
        gcmp::ElementId MechanicalSystemId;
        gcmp::ElementId MechanicalSystemTypeId;
        gcmp::ElementId DuctTypeId;  ///<风管类型Id
        gcmp::ElementId AssociatedPlaneId;///<关联平面Id(通常低部标高平面)
        gcmp::ElementCreationOptions CreationOption;///<创建状态：正常或者临时对象
        gcmp::UniIdentity CategoryUid;///<对象的Category
        bool Visible;///<可见性
        gcmp::Vector3d StartPoint; ///<起点（世界坐标系）
        gcmp::Vector3d EndPoint;///终点（世界坐标系）
        double BaseOffset;///<底部偏移，需要把IsUseBaseOffset设置成TRUE才有效果
        bool  IsUseBaseOffset;    ///<  true表示使用BaseOffset信息，false表示不使用BaseOffset信息，采用StartPoint和EndPoint相对关联平台的偏移值
        double Diameter;///<直径，mm(圆形风管)
        double Width;///<宽度，mm (矩形风管)
        double Height;///<高度，mm(矩形风管)
        gcmp::Vector3d CurveNormal;  ///<风管垂直于工作平面的方向(高度方向)
        HorizontalAlignment horizontalAlignment;    ///<水平对正
        VerticalAlignment verticalAlignment;    ///<垂直对正
    };

    /// \brief 风管类
    class GMEP_MODEL_INTERFACE_EXPORT IDuct : public IMepCurve
    {
        DEFINE_CAST_DERIVED(gmep::IDuct, gmep::IMepCurve)
    public:
        /// \brief 析构函数
        virtual ~IDuct() {}


        /// \brief 创建风管
        /// \param input 输入数据
        /// \return 风管指针。若数据不合理，创建失败会返回nullptr
        static IDuct* Create(const DuctInput &input);

        static gcmp::UniIdentity GetImplementationUid();

        ///.\ breif 根据两个点创建一个风管
        /// \ param pDocument 文档
        /// \ param ductTypeId 风管类型id
        /// \ param levelId 楼层平面id
        /// \ param startPoint 风管起始点坐标（世界坐标系）
        /// \ param endPoint 风管终点坐标（世界坐标系）
        static IDuct* Create(gcmp::IDocument* pDocument, const gcmp::ElementId& ductTypeId, const gcmp::ElementId& levelId, const gcmp::Vector3d& startPoint, const gcmp::Vector3d& endPoint);
    

        ///.\ breif 根据两个连接点创建一个管风管
        /// \ param pDocument 文档
        /// \ param systemTypeId 系统类型id
        /// \ param pipeTypeId 风管类型id
        /// \ param levelId 水平面id
        /// \ param pStartConnector 风管起始连接点
        /// \ param pEndConnector 风管终连接点
        static IDuct* Create(gcmp::IDocument* pDocument, const gcmp::ElementId& ductTypeId, const gcmp::ElementId& levelId, IConnector* pStartConnector, IConnector* pEndConnector);


        ///.\ breif 根据两个连接点创建一个管风管
        /// \ param pDocument 文档
        /// \ param systemTypeId 系统类型id
        /// \ param pipeTypeId 风管类型id
        /// \ param levelId 水平面id
        /// \ param pStartConnector 风管起始连接点
        /// \ param endPoint 风管终点坐标
        static IDuct* Create(gcmp::IDocument* pDocument, const gcmp::ElementId& ductTypeId, const gcmp::ElementId& levelId, IConnector* pStartConnector, const gcmp::Vector3d& endPoint);

        /// \brief 得到风管管线法向（截面Height方向）
        /// \return 风管管线法向
        virtual gcmp::Vector3d GetCurveNormal() const  = 0;


        /// \brief 设置风管管线法向（截面Height方向）
        /// \param curveNormal 风管管线法向
        /// \return 返回true表示成功，否则表示失败
        virtual bool SetCurveNormal(const gcmp::Vector3d& curveNormal) = 0;

        /// \brief 获取风管坡度
        ///
        /// \return double  返回风管坡度
        virtual double GetSlope() const = 0;

        /// \brief 设置风管坡度
        ///
        /// \param double slope 风管坡度 
        /// \return bool 是否设置成功
        virtual bool SetSlope(double slope) = 0;

        /// \brief 获得风管坡度关联更新
        ///
        /// \return RegenDataId 返回关联更新风管坡度数据ID
        virtual RegenDataId GetSlopeRdId() const = 0;

        /// \brief 标识风管坡度RdID
        ///
        /// \return void 
        virtual void MarkSlopeRdId() = 0;

        /// \brief 获取管道保温ElementID
        ///
        /// \return gcmp::ElementId  返回管道保温ElementID
        virtual gcmp::ElementId GetDuctInsulationId()const = 0;


        /// \brief 设置管道保温ElementID
        ///
        /// \param const gcmp::ElementId & pipeInsulationId  管内保温ElementID
        /// \return bool 返回是否设置成功
        virtual bool SetDuctInsulationId(const gcmp::ElementId& ductInsulationId) = 0;

        /// \brief 获得系统变化关联更新数据
        virtual RegenDataId GetMepSystemChangeRdId() const = 0;

        /// \brief 标记 系统变化关联更新数据
        virtual void MarkMepSystemChangeRdId() = 0;

        /// \brief 获得壁厚
        virtual double GetWallThickness()const = 0;

        /// \brief 获取管线编号
        /// 
        /// \return const std::wstring 返回管线编号
        virtual const std::wstring GetSerialNumber() const = 0;

        /// \brief 设置管线编号
        /// 
        /// \param std::wstring number 管线编号
        /// \return bool 是否设置成功
        virtual void SetSerialNumber(const std::wstring &number) = 0;  

        /// \brief 设置风管镜像标志位
        /// 
        /// \param bool isMirrored 是否已经镜像
        /// \return void
        virtual bool SetMirrored(bool isMirrored) = 0;

        /// \brief 获取风管镜像标志位
        /// 
        /// \return bool isMirrored 是否已经镜像
        virtual bool GetMirrored() const = 0;
        
    };
}
